export const clearHttpRequestingList = () => {
	if (window.$httpRequestList && window.$httpRequestList.length > 0) {
		window.$httpRequestList.forEach(item => {
			for (let key in item) {
				item[key]()
			}
		})
		window.$httpRequestList = []
	}
}

/**
 * 允许某个请求可以继续进行
 * @param {string} api_id 请求的唯一ID
 */
export const allowRequest = function (api_id) {
	window.$httpRequestList.forEach((item, i) => {
		for (let key in item) {
			if (key === api_id) {
				window.$httpRequestList.splice(i, 1)
			}
		}
	})
}

/**
 * 防抖
 * @param {string} api_id - 请求唯一id
 */
export const stopRepeatRequest = function (api_id) {
	window.$httpRequestList.forEach(item => {
		for (let key in item) {
			if (key === api_id) {
				item[key]()
			}
		}
	})
}
